package com.anti.modular.bus.busroom.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.busrealestate.param.BusRealEstateParam;
import com.anti.modular.bus.busroom.param.BusRoomParam;
import com.anti.modular.bus.busroom.service.BusRoomService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 房间表控制器
 *
 * @author anti
 * @date 2021-04-16 19:14:02
 */
@RestController
@RequestMapping("busRoom")
public class BusRoomController {

    @Resource
    private BusRoomService busRoomService;

    /**
     * 查询房间表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BusRoomParam busRoomParam) {
        return Result.data(busRoomService.page(pageParam,busRoomParam));
    }

    /**
     * 添加房间表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "房间表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusRoomParam.add.class) BusRoomParam busRoomParam) {
        busRoomService.add(busRoomParam);
        return Result.success("新增成功");
    }

    /**
     * 删除房间表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "房间表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusRoomParam.delete.class) BusRoomParam busRoomParam) {
            busRoomService.delete(busRoomParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑房间表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "房间表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusRoomParam.edit.class) BusRoomParam busRoomParam) {
            busRoomService.edit(busRoomParam);
        return Result.success("修改成功");
    }

    /**
     * 查看房间表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @GetMapping("detail")
    public Result detail(@Validated(BusRoomParam.detail.class) BusRoomParam busRoomParam) {
        return Result.data(busRoomService.detail(busRoomParam));
    }

    /**
     * 房间表列表
     *
     * @author anti
     * @date 2021-04-16 19:14:02
     */
    @GetMapping("list")
    public Result list(BusRoomParam busRoomParam) {
        return Result.data(busRoomService.list(busRoomParam));
    }

    /**
     *
     * @param busRoomParam
     * @return
     */
    @GetMapping("getRoomSelectedList")
    public Result getRoomSelectedList(BusRoomParam busRoomParam) {
        return Result.data(busRoomService.list(busRoomParam));
    }

    @GetMapping("getRoomListByEstateIdOnOwnerType")
    public Result getRoomListByEstateIdOnOwnerType(Long estateId,String name,int category) {
        return Result.data(busRoomService.getRoomListByEstateIdOnOwnerType(estateId,name,category));
    }
}
